from django.db import models

from goods.models import Foods
from user.models import UserModel
from shops.models import ShopsModel


class CartModel(models.Model):
    cart_id = models.IntegerField(primary_key=True)
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE)  # 关联用户
    food = models.ForeignKey(Foods, on_delete=models.CASCADE)  # 关联食物
    shop = models.ForeignKey(ShopsModel, on_delete=models.CASCADE)  # 关联商店
    number = models.IntegerField(default=1)  # 商品的个数
    is_select = models.IntegerField(default=1)  # 是否选择商品
    created_time = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'cart'
